// 封装常用功能
// 1.showloading
const loading = () => {
	uni.showLoading({
		title: 'loading...',
		icon: "none"
	})
}
// 2.hideLoading
const hideLoading = () => {
	uni.hideLoading()
}
// 3.通知提示信息
const notice = title => {
	uni.showToast({
		title,
		icon: 'none'
	})
}
// 4.本地存储token及过期时间
const refreshUser = info => {
	if (info.token) {
		uni.setStorageSync('uni_id_token', info.token)
	}
	if (info.tokenExpired) {
		uni.setStorageSync('uni_id_token_expired', info.tokenExpired)
	}
	if (info.userInfo.username) {
		uni.setStorageSync('username', info.userInfo.username)
	}
}
// 返回首页
const toHomePage = () => {
	uni.redirectTo({
		url: "/pages/index/index"
	})
}
const showModal=(e) =>{
				uni.showModal({
					title: '提示',
					content: '现在登录',
					success: function(res) {
						if (res.confirm) {
							// console.log('用户点击确定');
							uni.navigateTo({
								url: '../login/login'
							})
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			}
export default {
	loading,
	hideLoading,
	notice,
	refreshUser,
	toHomePage,
	showModal
}
